package com.ecommerce.dal.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ecommerce.dal.dao.impl.CategoryDAO;
import com.ecommerce.dal.entity.Category;
import com.ecommerce.dal.service.ICategoryManagerService;

@Service("categoryManagerService")
public class CategoryManagerService implements ICategoryManagerService {

	@Autowired
	CategoryDAO categoryDAO;

	@Override
	public Category retrieveCategory(long categoryId) {
		return categoryDAO.findByCategoryId(categoryId);
	}

	@Override
	public Category retrieveCategory(String categoryName) {
		return categoryDAO.findByCategoryName(categoryName);
	}

	@Override
	public void saveCategory(Category category) {
		categoryDAO.save(category);

	}

	@Override
	public List<Category> retrieveAllCategories() {
		// TODO Auto-generated method stub
		return categoryDAO.findAllCategories();
	}

	@Override
	public List<Category> retrieveAllSubCategories(long categoryId) {
		return categoryDAO.findAllSubCategories(categoryId);
	}

	@Override
	public void updateCategory(Category category) {
		categoryDAO.update(category);

	}

	@Override
	public void deleteCategory(Category category) {
		categoryDAO.delete(category);

	}

}
